<template>
  <div class="home">
    <input type="text" v-model="user" />
    <p v-show="show">用户名必须是6-18位的字母、数字、下划线</p>
    <button @click="login">登录</button>
  </div>
</template>

<script>
export default {
  name: "HomeView",
  components: {},
  data() {
    return {
      user: "",
      show: false,
    };
  },
  methods: {
    login() {
      let re = /^[\da-zA-Z_]{6,18}$/;
      if (re.test(this.user)) {
        this.$router.push("/about");
      } else {
        this.show = true;
      }
    },
  },
};
</script>
